package com.slz3.business.module.systemManagement.sysRole.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class SysRoleFactory {

    /**
     * 初始化基础属性值
     */
    public static SysRole initBaseFields(SysRole sysRole) {
        if (sysRole.getUuid() == null) {
            sysRole.setUuid(UUIDUtils.generateUUID());
            sysRole.setCreateTime(LocalDateTime.now());
            sysRole.setSerAudit(AuditFlag.APPROVED);
            if (VE.isEmpty(sysRole.getSerUsing())) {
                sysRole.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            sysRole.setLastModifyTime(LocalDateTime.now());
        }
        return sysRole;
    }

    /**
     * 初始化基础属性值
     */
    public static SysRole initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static SysRole newTemStyle() {
        return new SysRole();
    }

}
